<?php
/**
 * MAF
 **
 * File:
**/

/**
 * Class: MAF
 **
 * @package MAF
 * @subpackage Core
**/
class maf
	implements maf__i__singletone {

	const VERSION = "2.0";

	/**
	 * @return maf
	**/
	static public function getInstance() {

		static $instance;

		if( !isset($instance) ) {
			$instance = new self; }

		return $instance;

	}	# Function

	private function __clone() {
	}	# Function

	private function __construct() {
	}	# Function

	public function scanDirectory__forAutoload($_directory_) {

		foreach( glob($_directory_ . "/autoload.*.php", GLOB_NOSORT) as $_file ) {

			require_once $_file;

		}	# foreach

	}	# Function

	public function scanDirectory__forClasses($_directory_, $_prefix_ = "class.") {

		foreach( glob($_directory_ . "/{$_prefix_}*.php", GLOB_NOSORT) as $_file ) {

 			$_class = substr(basename($_file, ".php"), strlen($_prefix_));
			$this->getAutoload()->registerClass($_class, $_file);

		}	# foreach

	}	# Function

	/**
	 * @return maf__autoload
	**/
	public function getAutoload() {

		return maf__autoload::getInstance();

	}	# Function

	public function getVersion() {

		return self::VERSION;

	}	# Function

	public function registerE2E($_errors_ = E_ALL) {

		set_error_handler( array("maf__e2e", "catchError"), $_errors_ );
		set_exception_handler( array("maf__e2e", "catchException") );

	}	# Function

	public function registerAutoload() {

		spl_autoload_register( array("maf__autoload", "importClass") );

	}	# Function

}	# Class

/* EOF */